<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>地震局培训平台</title>
		<link rel="stylesheet" href="style/login.css" />
	</head>

	<body>
		<div id="show">
			<div class="loginbox">
				<div class="head"></div>
				<div class="main register">
					<div class="title"></div>
					<div class="box">
						<div class="text">已有账号<span class="loginbtn">直接登录</span></div>
					</div>
					<div class="inputbox">
						<input type="text" id="number" class="input" placeholder="请输入手机号 用于登录" />
						<input type="text" id="code" class="input" placeholder="请输入验证码" />
						<input type="password" id="password" class="input" placeholder="请设置密码" />
						<!-- <div class="refresh"></div> -->
						<div class="code">
							获取短信验证码
							<!-- <img src="image/l_code.png" id="imgcodeidimg"/> -->
						</div>
					</div>
					<div class="radio">同意注册协议</div>
					<div class="btn"></div>
					<div class="other">
						<div class="text">其他方式登录</div>
						<div class="xinlang"></div>
						<div class="weixin"></div>
						<div class="qq"></div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="script/jquery.min.js"></script>
		<script type="text/javascript" src="script/ishoock.tools.js"></script>
		<script type="text/javascript" src="script/common.js"></script>
		<script>
			//点击登录按钮
			$(".btn").on("click", function() {
				if($("#number").val() == "") {
					alert("请输入手机号！");
					return;
				}
				if($("#code").val() == "") {
					alert("请输入验证码！");
					return;
				}
				if($("#password").val() == "") {
					alert("请输入密码！");
					return;
				}
				if(!$(".radio").hasClass("in")) {
					alert("请先同意协议！");
					return;
				}
				$.ajax({
					type: "get",
					url: host + "user/checkCode",
					data: {
						"telphone": $("#number").val(),
						"code": $("#code").val(),
						"password": $("#password").val()
					},
					success:function(data){
						console.log(data);
						if(data.status=="fail"){
							alert(data.message);
						}else{
							alert("注册成功");
							window.location.href="login.html"
						}
					},
					error:function(){
						alert("注册失败");
					}
				});
			});
			//点击立即登录
			$(".loginbtn").on("click", function() {
				window.location.href = "login.html";
			});
			//点击同意协议
			$(".radio").on("click", function() {
				if($(this).hasClass("in")) {
					$(this).removeIn();
				} else {
					$(this).in();
				}
			});

			// 发送短信验证码
			$('.code').click(function() {
				var username = $("#number").val();
				if($("#number").val() == "") {
					alert("请输入手机号！");
					return;
				}
				$.ajax({
					type: "get",
					url: host + "user/sendRegistCode?telphone=" + username,
					async: true,
					dataType: "json",
					success: function(data) {

					},
				})
			})
		</script>
	</body>

</html>